import React from "react";
import Login from "../pages/login";
import Home from "../pages/home";
import CityList from "../pages/cityList";
import PriviteRouter from "./priviteRouter";
import My from "../pages/my";
import Layout from "../pages/layout";
import Home1 from "../pages/Home1";
import Detail from "../pages/detail";
import Show from "../pages/show";
import MyCollect from "../pages/myCollect";
import Chat from "../pages/chat";

// 1. 路由表
export const routesList = [
  {
    path: "/",
    element: Layout,
    children: [
      {
        path: "/",
        element: <Home></Home>,
      },
      {
        path: "/home1",
        element: <Home1></Home1>,
      },
      {
        path: "/my",
        element: <My></My>,
      },
    ],
  },
  {
    path: "/login",
    element: Login,
  },
  {
    path: "/cityList",
    element: CityList,
  },
  {
    path: "/detail/:id",
    element: Detail,
  },
  {
    path: "/show",
    element: Show,
  },
  {
    path: "/my/collect",
    element: MyCollect,
  },
  {
    path: "/chat",
    element: Chat,
  },
];

// 2. 处理路由表， 添加路由守卫功能
export const routes = routesList.map((v) => {
  return {
    ...v,
    element: <PriviteRouter v={v}></PriviteRouter>,
  };
});
